package com.chendx.store.goods.controller;

import com.chendx.model.common.dtos.ResponseResult;
import com.chendx.model.goods.dto.BrandDto;
import com.chendx.store.api.goods.BrandControllerApi;
import com.chendx.store.goods.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by chendx on 2022/4/19.
 */
@RestController
@RequestMapping("/api/goods/brand")
public class BrandController implements BrandControllerApi {

    @Autowired
    private BrandService brandService;

    @Override
    @PostMapping("/loadData")
    public ResponseResult loadBrand(BrandDto dto) {
        return brandService.loadBrand(dto);
    }

    @Override
    @GetMapping("/loadByCategory/{categoryId}")
    public ResponseResult loadByCategory(@PathVariable Integer categoryId) {
        return brandService.loadByCategory(categoryId);
    }

    @Override
    @GetMapping("/one")
    public ResponseResult one(Integer id) {
        return ResponseResult.okResult(brandService.getById(id));
    }


}
